package com.broheim.websocket.spring.config;

import com.broheim.websocket.core.listener.Listener;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class ListenerRegisterBean {
    private static Map<String, Set<Listener>> register = new HashMap<>();

    public void registerListener(String url, Listener listener) {
        Set<Listener> listeners = register.get(url);
        if (null == listeners) {
            listeners = new HashSet<Listener>();
            listeners.add(listener);
            register.put(url, listeners);
        } else {
            listeners.add(listener);
        }
    }

    public Map<String, Set<Listener>> getRegister() {
        return register;
    }

    public Set<Listener> getListener(String url) {
        return register.get(url);
    }
}
